package com.itheima.reggie.common;

/**
 * @author mff
 * @date 2022/6/9 15:06
 * @mood happy
 */
public class GlobalThread {

//    先在过滤器登录后获用户ID并存储
//    再在AOP时获得到threadLocal内的ID
//    最后在用放行后结果放回后清除threadLocal的内存信息，防止内存溢出
//    创建一个线程存储对象
    private static final ThreadLocal<Long> THREAD = new ThreadLocal<>();

    public static void setThread(Long id){
        THREAD.set(id);
    }

    public static Long getThread(){
        return THREAD.get();
    }

    public static void remove(){
        THREAD.remove();
    }

}
